<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      >
    <h:head>
        <link href="estilo/manutencaoCss.css" rel="stylesheet" type="text/css" />
        <title>Facelet Title</title>
    </h:head>
    <h:body>

        <p:layout fullPage="true">

            <p:layoutUnit position="north" size="100" resizable="true" closable="true" collapsible="true">
                tiyulo Tarci
            </p:layoutUnit>

            <p:layoutUnit position="south" size="100" closable="true" collapsible="true">
                Footer
            </p:layoutUnit>

            <p:layoutUnit position="east" size="200" header="Right" resizable="true" collapsible="true" effect="drop">
                <h:form id="formBotoes">

                    <p:menu>
                        <p:submenu label="Resources">
                            <p:menuitem value="Demo" url="http://www.primefaces.org/showcase-labs/ui/home.jsf" />
                            <p:menuitem value="Documentation" url="http://www.primefaces.org/documentation.html" />
                            <p:menuitem value="Forum" url="http://forum.primefaces.org/" />
                            <p:menuitem value="Themes" url="http://www.primefaces.org/themes.html" />
                        </p:submenu>

                    </p:menu>
                </h:form>
            </p:layoutUnit>

            <p:layoutUnit position="center">
                <h:form id="formConteudo">  

                    <p:messages id="mensagens" autoUpdate="true" />

                    <p:dataTable id="dataTable" styleClass="dataTable"  var="dt" value="#{atributoMBean.entidades}"  rows="25" paginator="true" 
                                 rowKey="#{dt}" selectionMode="multiple" selection="#{atributoMBean.entidadesSelecionadas}"
                                 emptyMessage="Não há registro para serem apresentados"
                                 rowsPerPageTemplate="10,25,50, 100"       
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                
                                 >  

                        <f:facet name="header">  
                            <div align="right">
                             <p:commandButton  actionListener="#{atributoMBean.prepararAdicionarEntidade}" icon="ui-icon-disk"
                                               value="Novo Registro" update=":formManutencaoDialog:display" onclick="modalmanutencao.show();"
                                               styleClass="botaoAcao"    />   
                             <p:commandButton   icon="ui-icon-disk"
                                                value="Excluir registros registro" update=":formConfirmExclusaoRegistros" 
                                                onclick="confirmaExclusaoRegistros.show();"
                                                styleClass="botaoAcao"    />   
                            </div>


                        </f:facet>  

                        <p:column headerText="Ações" >                                                          
                            <p:splitButton  icon="ui-icon-wrench">  
                                <p:menuitem value="Alterar Registro"  actionListener="#{atributoMBean.prepararAdicionarEntidade}"   icon="ui-icon-wrench" update=":formManutencaoDialog:display :formConteudo:dataTable"  oncomplete="modalmanutencao.show()" >
                                    <f:setPropertyActionListener target="#{atributoMBean.entidade}" value="#{dt}" />
                                </p:menuitem>
                                <p:menuitem value="Remover Registro"   icon="ui-icon-close" oncomplete="confirmaExclusao.show()"  update=":cascaConfirmExclusao :formConteudo:dataTable"   >
                                    <f:setPropertyActionListener target="#{atributoMBean.entidade}" value="#{dt}" />
                                </p:menuitem>
                                <p:separator />  
                                <p:menuitem value="Duplicar Registro"  actionListener="#{atributoMBean.prepararDuplicarEntidade}"   icon="ui-icon-copy" update=":formManutencaoDialog:display :formConteudo:dataTable"  oncomplete="modalmanutencao.show()"    >
                                    <f:setPropertyActionListener target="#{atributoMBean.entidade}" value="#{dt}"  />
                                </p:menuitem>   
                            </p:splitButton>  

                        </p:column>

                        <p:column sortBy="#{dt.id}" headerText="ID" filterBy="#{dt.id}"  >  
                            <h:outputText value="#{dt.id}" styleClass="teste" />  
                        </p:column>  

                        <p:column sortBy="#{dt.nome}" headerText="Nome" filterBy="#{dt.nome}" >  
                            <h:outputText value="#{dt.nome}" />  
                        </p:column>  
                       
                        <p:column sortBy="#{dt.descricao}" headerText="Descricao" filterBy="#{dt.descricao}" transient="true" > 
                          <div class="descricao">
                                <h:outputText value="#{dt.descricao}" style="width: 100px;" />  
                          </div>
                        </p:column>
                         <p:column sortBy="#{dt.ativo}" headerText="Ativo" > 
                              <p:selectBooleanButton  disabled="true" value="#{dt.ativo}" onLabel="Sim" offLabel="Não" onIcon="ui-icon-check" offIcon="ui-icon-close" />  
                         </p:column>
                        
                    </p:dataTable> 

                </h:form>  


            </p:layoutUnit>

        </p:layout>

        <p:dialog id="manutencaoModalEntidade"  header="Manutencao Atributo" widgetVar="modalmanutencao" resizable="false" modal="true"   >  
            <h:form id="formManutencaoDialog" >
                <h:panelGrid id="display"   columns="2" styleClass="coluna100" cellpadding="4" columnClasses="coluna30, coluna70" >  

                    <p:outputLabel value="Id:" />  
                    <p:outputLabel value="#{atributoMBean.entidade.id}"   />  

                    <p:outputLabel value="Nome:" for="nome" />  
                    <p:inputText styleClass="campoInput"   value="#{atributoMBean.entidade.nome}"  id="nome"/>  


                    <p:outputLabel value="Descricao" />  
                    <p:inputTextarea  styleClass="campoInput"  rows="2" value="#{atributoMBean.entidade.descricao}" style="font-weight:bold"/>  

                   <p:outputLabel value="Ativo" />  
                   <p:selectBooleanButton   value="#{atributoMBean.entidade.ativo}" onLabel="Sim" offLabel="Não" onIcon="ui-icon-check" offIcon="ui-icon-close" />  
                   
                   <p:commandButton styleClass="botao" icon="ui-icon-disk" actionListener="#{atributoMBean.salvaEntidade}" id="btnSalva" value="Salva" update=":formConteudo"  oncomplete="modalmanutencao.hide();"/>  

                </h:panelGrid>  
            </h:form>

        </p:dialog> 

        <h:panelGrid id="cascaConfirmExclusao">
            <p:confirmDialog id="confirmaDialogExclusao" message="Tem certeja que deseja excluir o registro  #{atributoMBean.entidade.nome} ?"
                             header="confirme" severity="alert" widgetVar="confirmaExclusao">
                <h:form id="formConfirmExclusao" >
                    <p:commandButton id="confirmaExclusao" value="sim" oncomplete="confirmaExclusao.hide()"  
                                     actionListener="#{atributoMBean.removerEntidade}" update=":formConteudo" />  
                    <p:commandButton id="cancelaExclusao" value="Cancelar" onclick="confirmaExclusao.hide();" type="button"  /> 
                </h:form>
            </p:confirmDialog> 

            <p:dialog id="confirmaDialogExclusaoRegistros"  modal="true"
                      header="confirme"  widgetVar="confirmaExclusaoRegistros">
                <h:form id="formConfirmExclusaoRegistros" >
                            <p:dataList value="#{atributoMBean.entidadesSelecionadas}" var="dtExclusao" id="listaEntidadesExclusao"  
                                        paginator="true" rows="10"   type="none" >  
                                <h:outputText value="#{dtExclusao.id}" />
                                <h:outputText value="#{dtExclusao.nome}" />
                                <br /> 

                            </p:dataList>

                    <h:panelGrid columns="2" id="displayExcluir" >
                        <p:commandButton id="confirmaExclusaoRegistros" value="sim" 
                                         oncomplete="confirmaExclusaoRegistros.hide()"  
                                         actionListener="#{atributoMBean.removerEntidadesSelecionadas}" update=":formConteudo" />  
                    <p:commandButton id="cancelaExclusaoRegistros" value="Cancelar" 
                                     onclick="confirmaExclusaoRegistros.hide();"  />

                    </h:panelGrid> 
                </h:form>
            </p:dialog>> 

        </h:panelGrid>




    </h:body>
</html>

